import axios from 'axios'

const request = axios.create({
  baseURL: 'https://restapi.amap.com/v3/geocode/regeo',
  timeout: 3000,
})

request.interceptors.response.use(
  (response) => {
    return response.data
  },
  (error) => {
    return Promise.reject(error)
  }
)

export const getLocation = (location) => {
  return request({
    url: `?output=JSON&location=${location}&key=4e1712017c948497d5f15dc23674ae05&radius=100&extensions=base`,
    method: 'get',
  })
}
